package com.eastfair.venueservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.eastfair.boot.service.SuperServiceImpl;
import com.eastfair.constant.BusinessConstant;
import com.eastfair.core.base.R;
import com.eastfair.core.context.ContextUtil;
import com.eastfair.venueservice.dao.ExhibitionManageResponsibilityerMapper;
import com.eastfair.venueservice.entity.ExhibitionManageResponsibilityer;
import com.eastfair.venueservice.service.ExhibitionManageResponsibilityerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Collection;
/**
 * <p>
 * 业务实现类
 * 场馆综合展会负责人
 * </p>
 *
 * @author linan
 * @date 2022-07-15
 */
@Slf4j
@Service
public class ExhibitionManageResponsibilityerServiceImpl extends SuperServiceImpl<ExhibitionManageResponsibilityerMapper, ExhibitionManageResponsibilityer> implements ExhibitionManageResponsibilityerService {


    /**
     * 处理逻辑删除相关处理
     *
     * @param modelList 实体
     * @return 是否成功
     */
    @Override
    protected R<Boolean> handlerRemoveByIdsOfLogic(Collection<ExhibitionManageResponsibilityer> modelList) {
        modelList.stream().forEach(s -> {
            s.setIsDeleted(BusinessConstant.YES);
        });
        // TODO: 2021/10/29 这里需要操作其他业务，如清空角色等
        return R.successDef();
    }


    @Override
    protected R<Boolean> handlerSave(ExhibitionManageResponsibilityer model) {
        model.setProjectId(ContextUtil.getProjectId());
        model.setSubsystemId(ContextUtil.getSubSystemId());
        return R.successDef();
    }

    @Override
    public Boolean removeByExhibitionManageId(Long exhibitionManageId) {
        UpdateWrapper<ExhibitionManageResponsibilityer> updateWrapper = new UpdateWrapper<>();
        updateWrapper.lambda().eq(ExhibitionManageResponsibilityer::getIsDeleted,BusinessConstant.NO).eq(ExhibitionManageResponsibilityer::getExhibitionManageId,exhibitionManageId)
                .set(ExhibitionManageResponsibilityer::getIsDeleted,BusinessConstant.YES);
        return update(updateWrapper);
    }
}
